package com.ruoyi.system.config;

import com.doudian.open.core.AccessToken;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.CommandLineRunner;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

@Order(6)
@Component
@Slf4j
public class HjfCommandLineRunner implements CommandLineRunner {
    public static String APP_KEY = "7329816210957157897";
    public static String APP_SECRET = "52608104-4ff0-49e2-9eac-54979eda8353";
    public static Long DIAN_PU_HAO = 104110047L;
    public AccessToken accessToken = new AccessToken();

    /**
     * 数码大超市服务器
     * @param args incoming main method arguments
     * @throws Exception
     *
     */
//    @Override
//    public void run(String... args) throws Exception {
//        GlobalConfig.initAppKey("7444805882086622760");
//        GlobalConfig.initAppSecret("a2ed7006-78e7-4614-b27f-c3e1080a0864");
//        accessToken = AccessTokenBuilder.build(175974257L); //入参为shopId
//        while (!accessToken.isSuccess()) {
//            log.info("Token 获取失败等待3秒继续,这个需要ip白名单内");
//            Thread.sleep(3000);
//            accessToken = AccessTokenBuilder.build(175974257L); //入参为shopId
//        }
//        log.info("Token 获取成功: {}", accessToken.getAccessToken());
//    }


    /**
     * 联通店铺
     *
     * @param args incoming main method arguments
     * @throws Exception
     */
    @Override
    public void run(String... args) throws Exception {
//        GlobalConfig.initAppKey(APP_KEY);
//        GlobalConfig.initAppSecret(APP_SECRET);
//        accessToken = AccessTokenBuilder.build(DIAN_PU_HAO); //入参为shopId
//        while (!accessToken.isSuccess()) {
//            log.info("联通店铺Token 获取失败等待3秒继续,这个需要ip白名单内");
//            Thread.sleep(3000);
//            accessToken = AccessTokenBuilder.build(104110047L); //入参为shopId
//        }
//        log.info("联通店铺Token 获取成功: {}", accessToken.getAccessToken());
    }

}